package org.example.struct.array;

/**
 * @author liyishan
 * @date 2023/8/7 09:41
 * @apiNote
 */

public class Test00674FindLengthOfLCIS {
    public static void main(String[] args) {
        int[] nums = {4,2,3};
        System.out.println(test(nums));

    }

    /**
     * 如果只有一个数据  return 1
     * 否则  从第二个数据开始，如果非递增 则记录下start  max和 i-start+1 作比较
     * @param nums
     * @return
     */
    public static int test(int[] nums) {
        int n = nums.length;
        int start = 0;
        int max = 1;
        for (int i = 1; i < n; i++) {
            if (nums[i] <= nums[i - 1]) {
                start = i;
            }
            max = Math.max(max, i - start + 1);
        }
        return max;
    }

    public int findLengthOfLCIS1(int[] nums) {
        int n = nums.length;
        if(n == 1){
            return 1;
        }
        int max = 0;
        int len = 1;
        for(int i = 1;i<n;i++){
            if(nums[i-1] < nums[i]){
                len++;
            }else{
                len = 1;
            }
            max = Math.max(max,len);
        }
        return max;
    }

}
